package org.example.spring.ioc;

import org.example.spring.ioc.bean.Car;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;


@SpringBootApplication
public class FactoryTest {
    public static void main(String[] args) {
        //FactoryBean在容器中组件的类型是接口中泛型指定的类型，而组件的名字是工厂自己的名字
        ConfigurableApplicationContext ioc = SpringApplication.run(FactoryTest.class, args);
        System.out.println("--------------------------------------------------------------");
        Car car1 = ioc.getBean(Car.class);
        System.out.println("car = " + car1);
        Car car2 = ioc.getBean(Car.class);
        System.out.println(car1 == car2);
    }
}
